﻿#include "welcome/welcome.h"
#include "ui_welcome.h"
#include "server/serverwindow.h"
#include "client/clientwindow.h"
#include "valdefs.h"

#include <QMessageBox>


Welcome::Welcome(QWidget *parent) : QWidget(parent), ui(new Ui::Welcome) {
    ui->setupUi(this);
    Init();
}


Welcome::~Welcome(void) {
    delete ui;
}


void Welcome::Init(void){
    connect(ui->buttonOpenClient, &QPushButton::clicked,
            this, &Welcome::OnButtonOpenClientClicked);
    connect(ui->buttonOpenServer, &QPushButton::clicked,
            this, &Welcome::OnButtonOpenServerClicked);
    connect(ui->buttonShowAbout, &QPushButton::clicked,
            this, &Welcome::OnButtonShowAboutClicked);
}


void Welcome::OnButtonOpenServerClicked(void){
    ServerWindow *w = new ServerWindow(nullptr);
    this->close();
    w->show();
}


void Welcome::OnButtonOpenClientClicked(void){
    ClientWindow *w = new ClientWindow(nullptr);
    this->close();
    w->show();
}


void Welcome::OnButtonShowAboutClicked(void){
    QMessageBox::information(this, tr("关于"), tr(ABOUT_TEXT));
}
